<template>
  <footer class="contract-us">
    <section class="contract-container">
      <header class="contract-header">
        <h4 class="contract-title">联系我们</h4>
        <p class="contract-desc">
          <span class="first-address">铜陵市义安区政务服务中心</span>
          <span class="second-address">2、铜陵大市场一期6A19号</span>
        </p>
        <p class="line"></p>
      </header>
      <div class="contract-main">
        <form class="contract-form">
          <label class="form-item" for="">
            <input
              v-model="form.type"
              type="text"
              placeholder="你想要什么服务类型"/>
          </label>
          <label class="form-item" for="">
            <input
              v-model="form.time"
              type="text"
              placeholder="多久之内需要？">
          </label>
          <label class="form-item" for="">
            <input
              v-model="form.money"
              type="text" placeholder="您的预算多少？">
          </label>
          <label class="form-item" for="">
            <input
              v-model="form.phone"
              type="text" placeholder="您的联系电话？">
          </label>
          <label class="form-item textarea-item" for="">
            <textarea
              v-model="form.des"
              cols="30" rows="10" placeholder="更多信息（非必填）"></textarea>
          </label>
          <label class="form-item button-form-item" for="">
            <button
              @click="submitContract"
              :loading="submit_loading"
              type="button"
              class="button contract-btn">
              {{submit_loading ? '正在提交' : '提交'}}
            </button>
          </label>
        </form>
        <div class="contract-sub">
          <div class="contract-logo">
            <img src="../assets/images/about_17.jpg" alt="">
          </div>
          <p class="phone-title">免费热线电话（微信同号）：</p>
          <p class="phone-text">188-0562-8708</p>
          <p class="phone-wechat">
            <span class="phone-time">咨询时间：9:00 ~ 18:00</span>
          </p>
          <p class="phone-also">服务时间： 7X24小时</p>
          <p class="phone-title">公众号：</p>
          <div class="pic">
            <img src="../assets/images/gzh.jpeg" alt="">
            <img src="../assets/images/gzh-user.jpeg" alt="">
          </div>
        </div>
      </div>
      <footer class="contract-footer">
        <div class="line"></div>
        <p class="contract-desc">友情链接：会计网 中国经济网</p>
        <copyright></copyright>
      </footer>
    </section>
  </footer>
</template>

<script>
  /**
   * @Author: lifuzhao
   * @Date: 2019-05-03
   * @Project: eabax
   */
  import copyright from './copyright'
  export default {
    name: 'contract',
    data() {
      return {
        form: {
          type: '',
          time: '',
          money: '',
          phone: '',
          des: ''
        },
        submit_loading: false
      }
    },
    computed: {
      disabled() {
        let form = this.form,
          disabled = false
        Object.keys(form).forEach(key => {
          if (key === 'des') {
            return
          }
          if (!form[key]) {
            disabled = true
          }
        })
        return disabled
      }
    },
    methods: {
      submitContract() {
        let form = this.form,
          disabled = this.disabled
        if (disabled) {
          this.$message({
            message: '请完善表单',
            type: 'error'
          })
          return
        }
        this.submit_loading = true
        this.$axios
          .$post('/api/v1/booking', form)
          .then(res => {
            this.submit_loading = false
            this.$message({
              message: '提交成功',
              type: 'success'
            })
            this.form = {}
          })
          .catch(res => {
            this.submit_loading = false
            this.$message({
              message: res.msg || '提交失败，请稍后再试',
              type: 'error'
            })
          })
      }
    },
    components:{
      copyright
    }
  }
</script>

<style lang="less">
  .contract-us {
    width: 100%;
    background-color: #43464b;
    padding: 80px 0;
    display: flex;
    flex-direction: row;
    justify-content: center;

    .contract-container {
      width: 1256px;
    }

    .contract-header {

    }

    .contract-title {
      font-size: 32px;
      color: #fff;
      line-height: 1;
      margin: 0;
    }

    .contract-desc {
      font-size: 14px;
      color: #ffffff;
      line-height: 1;
      display: flex;
      flex-direction: row;
      padding: 21px 0 27px;
      margin: 0;

      .first-address {
        padding-right: 10px;
        border-right: 1px solid #fff;
      }

      .second-address {
        padding-left: 10px;
        line-height: 14px;
      }
    }

    .line {
      width: 100%;
      height: 1px; /* no */
      background-color: #c6c6c6;
      opacity: 0.33;
    }

    .contract-main {
      padding: 32px 0;
      display: flex;
      flex-direction: row;
    }

    .contract-footer {
      position: relative;

      .contract-desc {
        padding-bottom: 0;
      }

      .copyright {
        position: absolute;
        bottom: -40px; /* no */
        left: 0;
        color: #eee;


      }
    }

    .contract-form {
      display: flex;
      flex-direction: row;
      flex-wrap: wrap;
      width: 832px;
      margin-left: -16px;

      button {
        display: inline-flex;
        justify-content: center;
        width: 400px;
        height: 36px; /* no */
        border-radius: 5px;
        background-color: #4f5257;
        color: #c6c6c6;;
        border: none;
        outline: none;
        cursor: pointer;
      }

      .form-item {
        display: inline-flex;
        width: 400px;
        box-sizing: border-box;
        margin-left: 16px;
        margin-bottom: 18px;

        input {
          width: 100%;
          height: 37px; /* no */
          padding: 0 14px;
          box-sizing: border-box;
          /*margin: 0 8px;*/
          background-color: #4f5257;
          color: #c6c6c6;
          border: none;
          outline: none;
          border-radius: 4px;
        }

        textarea {
          width: 100%;
          height: 124px; /* no */
          background-color: #4f5257;
          color: #c6c6c6;
          outline: none;
          border: none;
          border-radius: 4px;
          padding: 10px 14px;
          box-sizing: border-box;
        }

        &.button-form-item {
          margin-bottom: 0;
        }
      }

      .textarea-item {
        width: 816px;
      }
    }

    .contract-sub {
      flex-grow: 1;
      flex-shrink: 1;
      display: flex;
      flex-direction: column;
      text-align: right;

      img {
        height: 64px;
        width: auto;
      }

      p {
        line-height: 1;
      }
    }

    .phone-title {
      font-size: 12px;
      color: #c6c6c6;
      margin: 18px 0 0;
    }

    .phone-text {
      font-size: 40px;
      color: #ff6e17;
      margin: 16px 0 0;
    }

    .phone-wechat {
      font-size: 12px;
      color: #c6c6c6;
      margin: 16px 0 0;
    }

    .phone-time {
      margin: 0 0 0 8px;
    }

    .phone-also {
      font-size: 14px;
      color: #c6c6c6;
      margin: 26px 0 0;
    }

    .pic {
      padding-top: 26px;

      img {
        height: 120px;
        margin-left: 20px;
      }
    }
  }
</style>
